import { IToolTipItem } from "../../../../com/mui/manager/IToolTipItem";
import { GlobalClass } from "../../../../com/mui/core/GlobalClass";
import { GTextFormat } from "../../../common/GTextFormat";
import { ObjCreate } from "../common/ObjCreate";
import { Language } from "../../../../extend/language/Language";
import { SWFPlayer } from "../../scene/modle/SWFPlayer";
import { ActionType } from "../../scene/modle/data/ActionType";
import { WuXingPlayerInfo } from "../../model/wuxing/WuXingPlayerInfo";
import { ModelType } from "../../scene/modle/data/ModelType";
import { ToolTipInfo } from "../../model/ToolTipInfo";
import { FilterConst } from "../../../component/gconst/FilterConst";
import { ToolTipsManager } from "../../../../com/mui/manager/ToolTipsManager";
type int = number;
//class WuXingSkillItem
    
    export  class WuXingSkillItem /* flash.display.Sprite */ implements IToolTipItem
    {
        constructor(arg1: Object /* flash.display.MovieClip */, arg2: int, arg3: Boolean=true)
        {
            
            this._mc = arg1;
            this._wxIndex = arg2;
            this._skillEffect = arg3;
            this.initUI();
            return;
        }

        protected initUI(): void
        {
            this._mc.x = this._mc.width / 2;
            this._mc.y = this._mc.height / 2;
            this.addChild(this._mc);
            this.addEventListener(flash.events.MouseEvent.MOUSE_OVER, this.onMouseOverHandler);
            this._swfBody = new Object /* flash.display.Sprite */();
            this._swfBody.mouseChildren = false;
            this._swfBody.mouseEnabled = false;
            addChild(this._swfBody);
            this._lockMask = new Object /* flash.display.Sprite */();
            this._lockMask.mouseEnabled = false;
            this._lockMask.graphics.lineStyle(0, 0, 0);
            this._lockMask.graphics.beginFill(0, 0.4);
            this._lockMask.graphics.drawCircle(28, 28, 25);
            this._lockMask.graphics.endFill();
            this._lockMask.cacheAsBitmap = true;
            addChild(this._lockMask);
            this._skillName = GlobalClass.getBitmap("wxSkillFontSmall_" + this._wxIndex);
            this._skillName.x = (this._mc.width - this._skillName.width) / 2;
            this._skillName.y = 26;
            addChild(this._skillName);
            var loc1=new GTextFormat("", 12, 16776960, true);
            loc1.align = flash.text.TextFormatAlign.CENTER;
            this._levelTxt = ObjCreate.createTextField(Language.getString(26342), 0, 36, 60, 20, this, loc1);
            this._levelTxt.autoSize = flash.text.TextFieldAutoSize.CENTER;
            addChild(this._levelTxt);
            return;
        }

        /* internal  */onEffectLoadedHandler(arg1: SWFPlayer): void
        {
            if (this._wxInfo && this._wxInfo.mainAttribute == this._wxIndex) 
            {
                this._wxSkillEffect.updateFrame(ActionType.Stand, 1, true);
                this._wxSkillEffect.updateCurrentFrame(0);
                this._wxSkillEffect.play();
                this._wxSkillEffect.move(27, 27);
            }
            return;
        }

        public updateData(arg1: WuXingPlayerInfo): void
        {
            if (!arg1) 
            {
                return;
            }
            this._wxInfo = arg1;
            if (this._wxInfo.mainAttribute != this._wxIndex) 
            {
                if (this._wxSkillEffect) 
                {
                    this._wxSkillEffect.dispose();
                }
                if (!this._lockMask.parent) 
                {
                    addChildAt(this._lockMask, 1);
                }
                if (this._levelTxt.parent) 
                {
                    removeChild(this._levelTxt);
                }
            }
            else 
            {
                this._levelTxt.text = "LV." + this._wxInfo.skillLevel;
                if (!this._levelTxt.parent) 
                {
                    addChild(this._levelTxt);
                }
                if (this._lockMask.parent) 
                {
                    removeChild(this._lockMask);
                }
                if (this._skillEffect) 
                {
                    if (!this._wxSkillEffect) 
                    {
                        this._wxSkillEffect = new SWFPlayer();
                    }
                    if (!this._wxSkillEffect.parent) 
                    {
                        this._swfBody.addChild(this._wxSkillEffect);
                    }
                    this._wxSkillEffect.loadComplete = this.onEffectLoadedHandler;
                    this._wxSkillEffect.load("wxSkillEffect_" + this._wxIndex + ".swf", ModelType.WXSkillEffect, null);
                }
            }
            this.toolTipDataFunction = this.getToolTipData;
            return;
        }

        /* internal  */getToolTipData(): ToolTipInfo
        {
            if (this._wxInfo) 
            {
                return this._wxInfo.skillToolTipInfo(this._wxIndex);
            }
            return null;
        }

        public dispose(): void
        {
            this._toolTipDataFunction = null;
            if (this._wxSkillEffect) 
            {
                this._wxSkillEffect.dispose();
            }
            return;
        }

        /* internal  */onMouseOverHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            addEventListener(flash.events.MouseEvent.MOUSE_OUT, this.onMouseOutHandler);
            this.filters = [FilterConst.guideTipsFilter];
            return;
        }

        /* internal  */onMouseOutHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            removeEventListener(flash.events.MouseEvent.MOUSE_OUT, this.onMouseOutHandler);
            this.filters = null;
            return;
        }

        public get toolTipData()
        {
            if (this.toolTipDataFunction != null) 
            {
                return this.toolTipDataFunction();
            }
            return this._tooltipData;
        }

        public set toolTipData(arg1)
        {
            if (arg1 == null || arg1 == "") 
            {
                ToolTipsManager.unregister(this);
            }
            else 
            {
                ToolTipsManager.register(this);
            }
            this._tooltipData = arg1;
            return;
        }

        public set toolTipDataFunction(arg1: Function)
        {
            if (arg1 != null) 
            {
                ToolTipsManager.register(this);
            }
            else 
            {
                ToolTipsManager.unregister(this);
            }
            this._toolTipDataFunction = arg1;
            return;
        }

        public get toolTipDataFunction(): Function
        {
            return this._toolTipDataFunction;
        }

        /* internal */ /* var */_wxInfo: WuXingPlayerInfo;

        /* internal */ /* var */_mc: Object /* flash.display.MovieClip */;

        /* internal */ /* var */_swfBody: Object /* flash.display.Sprite */;

        /* internal */ /* var */_skillName: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_wxIndex: int;

        /* internal */ /* var */_skillEffect: Boolean;

        /* internal */ /* var */_levelTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */_wxSkillEffect: SWFPlayer;

        /* internal */ /* var */_lockMask: Object /* flash.display.Sprite */;

        /* internal */ /* var */_tooltipData;

        protected /* var */_toolTipDataFunction: Function;
    }
